package cn.ghb.eshop.sys.users.web;

import cn.ghb.eshop.sys.users.entity.User;
import cn.ghb.eshop.sys.users.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {

    private final UserService userService;

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    @RequestMapping("/user")
    public User getUsername(@RequestParam("id") Long id) {
        return userService.getById(id);
    }

    @GetMapping("/add")
    public boolean add(User user) {
        return userService.save(user);
    }

}
